<?php
/**
 *
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2019/5/28 14:36
 * @copyright PanxSoft Inc.
 */

namespace App\Http\Controllers\App\V1;


use App\Http\Controllers\ApiController;
use App\Models\RegisterAgreement;
use App\Services\Locale\AppLanguage;

class RegisterAgreementController extends ApiController
{
    const ROUTES = [
        'index' => 'app.v1.RegisterAgreement.index',
    ];

    /**
     * 注册协议
     *
     * @return array|\Illuminate\Http\Response
     * @throws \Exception
     */
    public function index()
    {
        $register_agreements = (new RegisterAgreement)
            ->filterLocaleLanguage()
            ->get();

        $register_agreement = $register_agreements->firstWhere('type', RegisterAgreement::TYPE_REGISTER_AGREEMENT);
        $user_policy = $register_agreements->firstWhere('type', RegisterAgreement::TYPE_USER_POLICY);

        return $this->response(compact('register_agreement', 'user_policy'));
    }
}